package com.toughsoftware.pins.adapter;

import java.sql.Date;

import org.joda.time.DateTime;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.toughsoftware.pins.R;
import com.toughsoftware.pins.data.bean.BnPin;

public class AdptrBnPinsByRange extends ArrayAdapter<BnPin> {
	
	Activity context;
	static DateTime dt2 = new DateTime(2005, 3, 26, 12, 0, 0, 0);
	static DateTime dt4 = new DateTime(2013, 3, 7, 24, 5, 10, 12);
	
	private static BnPin[] datosRange1 = 
	    	new BnPin[]{
	    		new BnPin("Pin Title 1",true, new Date(System.currentTimeMillis()), "Foto Pin 1", "Texto Pin 1"),
	    		new BnPin("Pin Title 2",true, new Date(dt2.getMillis()), "Foto Pin 2", "Texto Pin 2"),
	    		new BnPin("Pin Title 3",true, new Date(System.currentTimeMillis()), "Foto Pin 3", "Texto Pin 3"),
	    		new BnPin("Pin Title 4",true, new Date(dt4.getMillis()), "Foto Pin 4", "Texto Pin 4"),
	    		new BnPin("Pin Title 5",true, new Date(System.currentTimeMillis()), "Foto Pin 5", "Texto Pin 5")};
	
	private static BnPin[] datosRange2 = 
	    	new BnPin[]{
	    		new BnPin("Pin Title 1",true, new Date(System.currentTimeMillis()), "Foto Pin 1", "Texto Pin 1"),
	    		new BnPin("Pin Title 2",true, new Date(dt2.getMillis()), "Foto Pin 2", "Texto Pin 2"),
	    		new BnPin("Pin Title 3",true, new Date(System.currentTimeMillis()), "Foto Pin 3", "Texto Pin 3"),
	    		new BnPin("Pin Title 4",true, new Date(dt4.getMillis()), "Foto Pin 4", "Texto Pin 4"),
	    		new BnPin("Pin Title 5",true, new Date(System.currentTimeMillis()), "Foto Pin 5", "Texto Pin 5")};
	
	
	public AdptrBnPinsByRange(Fragment context) {
		super(context.getActivity(), R.layout.pin_bean, datosRange1);
		this.context = context.getActivity();
	}
	
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View item = inflater.inflate(R.layout.pin_bean, null);
		
		TextView tvPinTitle = (TextView)item.findViewById(R.id.tvPinTitle);
		tvPinTitle.setText(datosRange1[position].getStrPinTitle());
		
		TextView tvPinWhen = (TextView)item.findViewById(R.id.tvPinWhen);
		tvPinWhen.setText(datosRange1[position].getDtPinWhen().toString());
		
		return(item);
	}
}
